﻿using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Data.Services.Common;
using System.Linq;
using System.ServiceModel.Web;
using System.Web;
using System.ServiceModel;
using System.Data.Services.Providers;
using Skynet.ServiceImplementation;

namespace SkynetWebServices
{
    [ServiceBehavior(IncludeExceptionDetailInFaults=true)]
    public class SkynetSupportService :
        DataService<Skynet.ServiceImplementation.SkynetSupportService>, 
        IServiceProvider
    {        
        public static void InitializeService(DataServiceConfiguration config)
        {
            config.UseVerboseErrors = true;
            config.SetEntitySetAccessRule("Supports", EntitySetRights.All);
            config.SetEntitySetAccessRule("Photos", EntitySetRights.All);
            // config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
            
        }
        protected override void HandleException(HandleExceptionArgs args)
        {
            base.HandleException(args);
        }
        public object GetService(Type serviceType)
        {
            if (serviceType == typeof(IDataServiceStreamProvider))
            {
                return new SkynetStreamProvider();
            }
            return null;

        }
    }
}

